<script>
<?php $this->placeholder('onReady')->captureStart() ?>
    $("#<?php echo $this->id_tablesorter?>").tablesorter(); 
    

    $( ".slider" ).slider({
        	value:0,
			min: 0,
			max: 100,
			step: 10,
            animate: true,
			slide: function( event, ui ) 
            {
				$(this).next().html( ui.value +'%').removeClass('ui-state-highlight').removeClass('ui-state-error');
			},
            stop: function( event, ui ) 
            {
               var aux= this.id.split('_')
               id=aux[1]
               $(this).next().append('<img src="/img/loader.gif"/>');
               $.getJSON('/to-do/value',{value:ui.value,id_tarea:id}, function(data){
                    $.taconiteJson(data)
               });

			}
    }).each(function(index) {
        $(this).slider( "value" ,parseInt($(this).next().html()))
    });
    
    
    
    $('.sgit_filtro').on("change",'select[name=id_zona]', function(e){ 
        loadCombos(this.value)
        
    })
    
    var zonapreselect='<?=$this->values['id_zona']?>';
    if(zonapreselect!='')
    {
        loadCombos(zonapreselect)
    }
    

    
<?php $this->placeholder('onReady')->captureEnd() ?>




</script>


<?
$script = <<<SCRIPT
function loadCombos(zona){
    $.getJSON("/to-do/combos/idZona/"+zona,{select:'.sgit_filtro',selected_pro:'{$this->values['id_proyecto']}',selected_cli:'{$this->values['id_cliente']}'}, function(result) {
        $.taconiteJson(result)
    });
}
SCRIPT;


if($script)$this->headScript()->appendScript($script);
?>

<?php echo $this->anchor($this->controllerName.'/insertar/tipo/'.$this->tipo,'Añadir Tarea',array('class'=>'utiladd'));?>

<?if($this->rows):?>


<div class="contenedor_tablesorter">

<table id="<?php echo $this->id_tablesorter?>" width="100%" class=""> 
    <?=$this->partial('snnipet/caption.phtml',array('c' => count($this->rows)));?>
    <thead>
		<tr>
            <th><?php echo $this->translate("Datacenter");?> </th>
            <th><?php echo $this->translate("Tarea");?> </th>
            <th><?php echo $this->translate("Proyecto/Cliente");?> </th>
            <th><?php echo $this->translate("Asignado a:");?> </th>
            <th><?php echo $this->translate("Fecha Inicio")?></th>
            <th><?php echo $this->translate("Fecha Compromiso")?></th>
            <th><?php echo $this->translate("Avance")?></th> 
            <th><?php echo $this->translate("Notas")?></th> 
            <th class="configure"></th> 
    	</tr>
    </thead>
    <tbody>
    <?foreach($this->rows as $row): ?>
        <tr class="tr_<?php echo $row['id']?>" >
            <td><?php echo $row['zona'];?></td>
            <td><?php echo $this->text($row['tarea']);?></td>
            <td>
            <?if($row['id_cliente']):?>
            <?=$this->anchor('proyecto/ficha/id_proyecto/'.$row['id_cliente'],$row['proyecto'],null,false)?>
            <?elseif($row['id_proyecto']):?>
            <?=$this->anchor('proyectosdc-post/index/id_proyecto/'.$row['id_proyecto'],$row['proyecto'],null,false)?>
            <?endif?>
            </td>
            <td><?php echo $this->user($row['usuario_asignado']);?></td>
            <td><?php echo $this->dateTo($row['fecha_ini']);?></td>
            <td><?php echo $this->dateTo($row['fecha_fin']);?></td>
            <td width="205"><div class="slider" id="value_<?=$row['id']?>"></div><span class="slider_level" id="slider_<?=$row['id']?>"><?=$row['avance']?>%</span></td>
            <td><?php echo $this->text($row['notas']);?></td>
            <td>
               <div class="botones">
    		     <?=$this->editarFila($this->controllerName,$row['id']);?>
                 <?=$this->borrarFila($this->controllerName,$row['id']);?>
   		      </div>
            </td>
        </tr>
    <?endforeach?>
    </tbody>
</table>

</div>
<?else: echo $this->partial('snnipet/atencion.phtml',array('msg'=>'No se han encontrado resultados'));endif?>
